package com.boco.transnms.server.bo.workflow;


import com.boco.transnms.common.dto.base.DboCollection;
import com.boco.transnms.common.dto.base.BoQueryContext;
import com.boco.common.util.except.UserException;
import java.util.*;


import com.boco.transnms.server.dao.base.DaoName;
import com.boco.transnms.server.bo.base.AbstractBO;
import com.boco.transnms.server.dao.workflow.*;
import com.boco.transnms.server.bo.ibo.workflow.IOutlineBO;
import com.boco.transnms.common.dto.WfOutline;
import com.boco.transnms.common.dto.base.BoActionContext;
import com.boco.transnms.common.dto.workflow.WfWorkList;
import com.boco.transnms.server.bo.base.BoName;
import com.boco.transnms.server.bo.ibo.workflow.IAttempDgnSheetBO;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class OutlineBO extends AbstractBO implements IOutlineBO{
    public OutlineBO() {
    }
    public void addLine(BoActionContext context,WfOutline line) throws UserException {
        try {
            this.getOutlineDAO().addLine(context, line);
        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
    }
    public void modifyLine(BoActionContext context,WfOutline line) throws UserException {
        try {
            this.getOutlineDAO().modifyLine(context, line);
        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
    }
    public void deleteLineByKey(BoActionContext context,String processKey){
        try {
            getOutlineDAO().deleteLineByKey(context, processKey);
        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
    }
    public WfOutline getLineByKey(BoActionContext context,String processKey)throws UserException{
        WfOutline rtn = null;
        try{
           rtn = this.getOutlineDAO().getLineByKey(context,processKey);

        }catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
        return rtn;
    }


    public WfOutline getOutlineBySheetId(BoActionContext context, String rplSheetCuid) throws UserException {
        WfOutline rtn = null;
        try {
            rtn = this.getOutlineDAO().getLineBySheetId(context,rplSheetCuid);

        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
        return rtn;
    }



    public DboCollection getHistoryList(BoQueryContext queryContext,String processType,String labelCn) throws UserException {
        DboCollection rtn = null;
        List formList = new ArrayList();
        try {
            rtn = this.getOutlineDAO().getHistoryList(queryContext, processType,labelCn);
        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
        return rtn;
    }

    public DboCollection getAllList(BoActionContext actionContext,HashMap map){
        DboCollection rtn = null;
        try {
            rtn = this.getOutlineDAO().getAllList(actionContext, map);
        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
        return rtn;
    }
/*    public DboCollection getHistoryList(BoQueryContext queryContext,HashMap map) throws UserException {
        DboCollection rtn = null;
        List formList = new ArrayList();
        try {
            rtn = this.getOutlineDAO().getWorkList(queryContext, map);
        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
        return rtn;
    }*/
    public DboCollection getWorkList(BoQueryContext queryContext,HashMap map) throws UserException {
        DboCollection rtn = null;
        List formList = new ArrayList();
        try {
            rtn = this.getOutlineDAO().getWorkList(queryContext, map);
        } catch (Exception ex) {
            throw new UserException(ex.getMessage());
        }
        return rtn;
    }

    public String getWorkCuids(BoQueryContext queryContext,HashMap map) throws Exception {
        String sheetCuids = "";
        DboCollection rtn = null;
        rtn = this.getOutlineDAO().getWorkList(queryContext, map);
        if(rtn!=null && rtn.size()>0){
            for(int i=0;i<rtn.size();i++){
                WfOutline outline = new WfOutline();
                outline = (WfOutline) rtn.getAttrField(outline.getClassName(), i);
                sheetCuids += "," + outline.getRelatedSheetCuid();
            }
            sheetCuids = sheetCuids.substring(1);
        }
        return sheetCuids;
    }


    public OutlineDAO getOutlineDAO(){
      return (OutlineDAO) super.getDAO(DaoName.OutlineDAO);
    }




}
